﻿using FRMS.BUS;
using FRMS.DAL;
using FRMS.Model;
using Quartz;
using System.Collections.Generic;
using System.Threading.Tasks;

namespace FRMS.TimedTask
{
    public class SyncService : IJob
    {
        public async Task Execute(IJobExecutionContext context)
        {
            try
            {
                AuditDAL auditDAL = new AuditDAL();
                List<VoucherInfo> list = auditDAL.QueryQRCodeVoucher();
                if (list != null && list.Count > 0)
                {
                    VoucherBUS voucherBUS = new VoucherBUS();
                    foreach (var item in list)
                    {
                        voucherBUS.SyncQRCodeVoucher(item);
                    }
                }

                List<FrmsAuditInfo> frmsAuditInfos = auditDAL.QueryQRCodeAuditInfo();
                if (frmsAuditInfos != null && frmsAuditInfos.Count > 0)
                {
                    AuditBUS auditBUS = new AuditBUS();
                    foreach (var item in frmsAuditInfos)
                    {
                        auditBUS.SyncAuditState(item);
                    }
                }
            }
            catch
            {

            }
        }
    }
}
